﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using PetaPoco;
using GsnHelper;
namespace ZhongheCms.Models
{
    public partial class GswTblJobInfoAll
    {
        [ResultColumn]
        public List<GswTblBaseInfo> JobBaseInfos { get; set; } 
        
        public static Page<GswViewJobInfoAll> GetJobInfoAll(string sdate,string edate,string keywords,int ownId,int pageIndex)
        {
            var sql = "select * from GswViewJobInfoAll where ParentId="+ownId;
            int flag = 0;
            if (InputValid.IsDate(sdate) && InputValid.IsDate(edate))
            {
                flag = 1;
                sql += " and PubDate>='" + sdate + "' and PubDate<='" + edate + "'";
            }
            if (!string.IsNullOrEmpty(keywords))
            {
                flag = 1;
                sql += " and JobName like '%" + keywords + "'";
            }
          
            if (flag == 0)
                sql += " and EndDate>='" + DateTime.Today.ToShortDateString() + "'";
            sql += " order by PubDate desc";
            var db = new ZhongheRepo();
            var pageList = db.Page<GswViewJobInfoAll>(pageIndex, 20, sql);
            return pageList;
        }
    }
}